package org.example.testgis.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.example.testgis.entity.PointTest;

@Mapper
public interface PointTestMapper extends BaseMapper<PointTest> {

    static final String FIND_GEOJSON_SQL = "<script>"
            + "select st_asgeojson(geom) as geomJson from point_test "
            + "where id = #{id} "
            + "<if test='null != name'>and p.name like concat('%', #{name}, '%')</if>"
            + "</script>";

    @Select(FIND_GEOJSON_SQL)
    PointTest findGeoJsonById(@Param("id") Long id, @Param("name") String name);
}
